package com.hrm.controller;

import com.hrm.dto.ResponseDTO;
import com.hrm.entity.Room;
import com.hrm.service.RoomService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/att_room")
public class RoomController {
    @Resource
    private RoomService roomService;

    @ApiOperation("新增")
    @PostMapping
    public ResponseDTO add(@RequestBody Room room) {
        return this.roomService.add(room);
    }

    @ApiOperation("逻辑删除")
    @DeleteMapping("/{id}")
    public ResponseDTO delete(@PathVariable Integer id) {
        return this.roomService.deleteById(id);
    }

    @ApiOperation("批量逻辑删除")
    @DeleteMapping("/batch/{ids}")
    public ResponseDTO deleteBatch(@PathVariable List<Integer> ids) {
        return this.roomService.deleteBatch(ids);
    }

    @ApiOperation("编辑更新")
    @PutMapping
    public ResponseDTO edit(@RequestBody Room room) {
        return this.roomService.edit(room);
    }

    @ApiOperation("查询")
    @GetMapping("/{id}")
    public ResponseDTO findById(@PathVariable Integer id) {
        return this.roomService.findById(id);
    }

    @ApiOperation("分页条件查询")
    @GetMapping
    public ResponseDTO list(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size) {
        return this.roomService.list(current, size);
    }

    @ApiOperation("分页")
    @GetMapping("/staff")
    public ResponseDTO findByStaffId(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, Integer id) {
        return this.roomService.findByStaffId(current, size, id);
    }

}

